<template>
  <t-layout-page class="t_module_form_demo">
    <t-layout-page-item>
      <el-form :model="form" label-width="auto" style="max-width: 600px" class="form_main">
        <el-form-item label="快捷流程意见">
          <el-select v-model="form.desc" placeholder="Select" size="large" style="width: 240px" @change="selchange">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="我的流程意见">
          <el-input v-model="form.comment" type="textarea" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="approvalClick(1)" :disabled="statusVal">同意</el-button>
          <el-button type="primary" @click="approvalClick(0)" :disabled="statusVal">驳回</el-button>
          <el-button type="primary" @click="back">关闭</el-button>
        </el-form-item>
      </el-form>
    </t-layout-page-item>
  </t-layout-page>
</template>
<script lang="ts" setup>
import { reactive, toRaw, ref } from 'vue'
// import { agreeOrDisAgree } from '@/api/modules/gzl'
import { useMessage } from '@/hooks/message'
import { useRoute } from 'vue-router'
// import { useUserStore } from "@/stores/user";
// const userStore = useUserStore();// 获取用户信息
// const { loginName,userCname} = toRaw(userStore.userInfo)
const route = useRoute()
const statusVal = ref(false)
const form = reactive({
  comment: '同意',
  desc: '同意',
})
const options = [
  {
    label: '同意',
    value: '同意',
  },
  {
    label: '拒绝',
    value: '拒绝',
  },
  {
    label: '需要补充材料',
    value: '需要补充材料',
  },
]
const selchange = (val) => {
  form.comment = val
}
const approvalClick = (type) => {
  saveApiFunc(type)
}
const back = () => {
  // router.push({
  //     path:'/liuchengchuli/dbsy'
  // })
  window.history.go(-1)
}
async function saveApiFunc(type) {
  const params = {
    approvalResult: type,
    bpmUser: {
      userId: loginName,
      userName: userCname,
    },
    comment: form.comment,
    // limit: 0,
    // offset: 0,
    processDefinitionKey: '',
    processInstanceId: route.query.activeKey,
    taskStatus: 'open',
  }
  const { success, data } = await agreeOrDisAgree(params)
  if (success) {
    statusVal.value = true
    useMessage().success(data.MSG)
  }
}
</script>
<style lang="less" scoped>
.form_main {
  margin-left: 20px;
}
</style>
